<template>
<view class="container">
	<block>
		<view class="orderinfo" v-if="facepayqr">
			<view class="item">
				您的收款码
			</view>
			<view class="qrcode">
				<image :src="facepayqr" mode="widthFix"></image>
			</view>
			<view class="flex-content">
				<view @click="download()" class="facepay" :style="{background:t('color2')+''}">
					<view class="tel_online">
						下载收款码
					</view>
				</view>
			</view>
		</view>
		<view class="orderinfo2" v-else>
			暂无收款码
		</view>
	</block>
	<dp-tabbar :opt="opt"></dp-tabbar>
	<popmsg ref="popmsg"></popmsg>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
		opt:{},
		loading:false,
		isload: false,
		menuindex:-1,
		
		facepayqr:''
    };
  },

  onLoad: function (opt) {
		this.opt = app.getopts(opt);
		this.getdata();
  },
	onPullDownRefresh: function () {
		this.getdata();
	},
  methods: {
		getdata: function () {
			var that = this;
			that.loading = true;
			app.get('AdminIndex/setinfo', {}, function (res) {
				that.loading = false;
				if (res.status == 2) {
					app.alert(res.msg, function () {
						app.goto('/admin/index/index', 'redirect');
					})
					return;
				}
				that.info = res.info;
				var bid = that.info.id
				var path ='pages/facepay/pay?bid='+bid;
				app.get('AdminOrder/getwxqrcode', {path: path}, function (res) {
					that.facepayqr = res.facepayqr
				});
			});
		},
		download:function(pics){
			var that = this;
			var pic = that.facepayqr;
			app.showLoading('图片保存中');
			uni.downloadFile({
				url: pic,
				success (res) {
					if (res.statusCode === 200) {
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success:function () {
								app.showLoading(false);
								app.success('已保存到相册');
							},
							fail:function(){
								app.showLoading(false);
								app.error('保存失败');
							}
						})
					}
				},
				fail:function(){
					app.showLoading(false);
					app.error('下载失败');
				}
			});
		},
  }
};
</script>
<style>
.orderinfo{ width:94%;margin:20rpx 3%;border-radius:5px;padding:20rpx 20rpx;padding: 14rpx 3%;background: #FFF;min-height: 400rpx;}
.orderinfo2{
	width:94%;margin:20rpx 3%;border-radius:5px;padding:20rpx 20rpx;padding: 14rpx 3%;background: #FFF;min-height: 400rpx;
	text-align: center;
	    padding-top: 148rpx;
}
.orderinfo .item{
	text-align: center;
	font-size: 32rpx;
	color: #999;
	padding: 30rpx 0rpx;
}
.qrcode{
	    margin: auto;
	    text-align: center;
}
.qrcode image{
	width: 100%;
	height: 1060rpx;
}

.flex-content{
	display: flex;
	padding: 66rpx 0rpx;
	margin:auto;
	width: 50%;
}
.flex-content .facepay {
	margin-left: 24rpx;
	font-size: 28rpx;
	color: #fff;
	padding: 20rpx 80rpx;
	border-radius: 24rpx;
	font-weight: normal;
	margin: auto;
}
</style>